<?php
declare (strict_types = 1);

namespace app\common\command\pachong\book;

use app\common\model\pachong\book\PachongBook;
use think\console\Command;
use think\console\Input;
use think\console\Output;

class CommandBookChapter extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('hello')
            ->setDescription('the hello command');
    }

    protected function execute(Input $input, Output $output)
    {
        while (true){
            // 查找没有完结，且刷新时间是7天前的
            $PachongBookObj = PachongBook::instance()->where([['is_over','=', 0],['update_time','<=', date("Y-m-d H:i:s", time() - 7 * 86400)]])->findOrEmpty()->toArray();
            if(empty($PachongBookObj)){
                // 没有数据就休息一天
                sleep(86400);
            }
            print_r($PachongBookObj);die;
        }
    }

}
